<template>
  <view class="wms-statistics-card" @click="handleClick">
    <view class="card-header">
      <text class="card-icon">{{ data.icon }}</text>
      <text class="card-title">{{ data.title }}</text>
    </view>
    <view class="card-content">
      <view 
        class="stat-item" 
        v-for="item in data.items" 
        :key="item.key"
      >
        <text class="stat-label">{{ item.label }}</text>
        <view class="stat-value-container">
          <text :class="['stat-value', item.alertClass]">{{ item.value }}</text>
          <text v-if="item.alert" class="alert-icon">{{ item.alertIcon }}</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'WmsStatisticsCard',
  props: {
    data: {
      type: Object,
      required: true
    }
  },
  methods: {
    handleClick() {
      if (this.data.clickable) {
        this.$emit('click', this.data);
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.wms-statistics-card {
  background: #ffffff;
  border-radius: 16rpx;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
  margin-bottom: 24rpx;
  padding: 32rpx;
  transition: all 0.3s ease;
}

.wms-statistics-card:active {
  transform: scale(0.98);
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.15);
}

.card-header {
  display: flex;
  align-items: center;
  margin-bottom: 24rpx;
  padding-bottom: 20rpx;
  border-bottom: 1rpx solid #f0f0f0;
}

.card-icon {
  font-size: 40rpx;
  margin-right: 16rpx;
}

.card-title {
  font-size: 32rpx;
  font-weight: 600;
  color: #262626;
}

.card-content {
  display: flex;
  flex-direction: column;
  gap: 20rpx;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12rpx 0;
}

.stat-label {
  font-size: 28rpx;
  color: #666666;
  flex: 1;
}

.stat-value-container {
  display: flex;
  align-items: center;
  gap: 12rpx;
}

.stat-value {
  font-size: 32rpx;
  font-weight: 500;
  color: #262626;
}

.stat-value.normal {
  color: #262626;
}

.stat-value.success {
  color: #52c41a;
}

.stat-value.warning {
  color: #fa8c16;
}

.stat-value.danger {
  color: #ff4d4f;
}

.alert-icon {
  font-size: 28rpx;
  color: #ff4d4f;
}
</style>
